
<meta charset="utf-8">

<div class="box" id="biz_pmpTasks_conatainer">
	<div class="box-header with-border">
		<form id="biz_pmpTasks_searchForm" role="form" class="form-inline">
			
			<div class="form-group">
				<label>任务名称</label> 
				<input name="taskName" v-model="searchForm.taskName" id="taskName" type="text" placeholder="" class="form-control">
			</div>
			<div class="form-group">
				<label>任务负责人</label> 
				<select type="text"
					name="chargeUserId" v-model="searchForm.chargeUserId"
					v-kselect="{url:'/pmp/service/ma/pmpCloudMember/loadCloudMemberComboboVo',vmodel:'pmpRequire.chargeUserId',firstEmpty:'true'}"
					class="form-control" id="chargeUserId">
				</select>
			</div>
			
			<div class="form-group">
				<label>任务状态</label> 
				<select id="status" name="status" v-model="searchForm.status" class="form-control">
					<option value="">请选择数据</option>
					<option value="1">未指派</option>
					<option value="2">未开始</option>
					<option value="3">进行中</option>
					<option value="4">已提交</option>
					<option value="5">被驳回</option>
					<option value="6">已完成</option>
					<option value="-1">已删除</option>
				</select>
			</div>
			<div class="form-group">
				<label>难度系数</label> 
				<select id="difficultyScoreId" name="difficultyScoreId" v-model="searchForm.difficultyScoreId"
					v-kselect="{url:'/pmp/service/pub/pmpALine/loadDifScoreComboboVo',vmodel:'searchForm.difficultyScoreId',firstEmpty:'true'}"
					class=" form-control">
				</select>
				
				
			</div>
			
			<div class="form-group">
				<label>项目版本</label> 
				<select type="text"
					name="projectVersionId" v-model="searchForm.projectVersionId"
					v-kselect="{url:'/pmp/service/pub/pmpProjectVersion/loadVersionComoboVo',ajaxKey:'projectId',vmodel:'searchForm.projectVersionId',firstEmpty:'true'}"
					class="form-control" id="chargeUserId">
				</select>
			</div>
                         
			<button type="button" class="btn btn-info pull-right m-t-n-xs" v-on:click="search">
				<strong>查询</strong>
			</button>
		</form>
	</div>
	<div class="box-body">
				<div class="btn-group " id="pmpTasksTableToolbar" role="group">
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="add">
						<i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 创建任务
					</button>
				
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="assign">
						<i class="glyphicon glyphicon-share" aria-hidden="true"></i> 指派任务
					</button>
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" 	v-on:click="assignHours">
						<i class="glyphicon glyphicon-time" aria-hidden="true"></i> 指派时间
					</button>
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" 	v-on:click="assignVersion">
						<i class="glyphicon glyphicon-tags" aria-hidden="true"></i> 修改版本
					</button>
					
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="difficultyScore">
						<i class="glyphicon glyphicon-warning-sign" aria-hidden="true"></i> 调整难度
					</button>
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="expireTime">
						<i class="glyphicon glyphicon-hourglass" aria-hidden="true"></i> 截止时间
					</button>
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="check">
						<i class="glyphicon glyphicon-floppy-open" aria-hidden="true"></i> 任务验收
					</button>
					<!-- <button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="split">
						<i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 拆分任务
					</button> -->
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="submit">
						<i class="glyphicon glyphicon-export" aria-hidden="true"></i> 提交工时
					</button>
					
				<!-- 	<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="submit">
						<i class="glyphicon glyphicon-open" aria-hidden="true"></i> 提交任务
					</button> -->
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="deletex">
						<i class="glyphicon glyphicon-trash" aria-hidden="true"></i> 删除
					</button>
				</div>
			<table id="pmpTasksBootstrapTable" data-mobile-responsive="true"></table>
	</div>
</div>


<script>



var taskMain=new Vue({  
	  el: '#biz_pmpTasks_conatainer',
	  data:{
		  projectId: project_detail_main.$data.projectId,
		  searchForm:{
			  projectId :project_detail_main.$data.projectId,
			  projectVersionId : null,
			  chargeUserId: null,
			  taskName : null,
			  status : null,
			  expiryTime: null,
			  difficultyScoreId : null
		  },
		  bus:new Vue(),
	  },
	  mounted:function(){
		  var _this=this;
		  _this.initTable();
	  },
    methods: {
  	  initTable:function(){
  		var _this=this;
  		var columns=[
  					{checkbox:true},
  					{field:'project_version_name',title:'版本',width:30},
  					{field:'task_name',title:'任务名称',width:160},
  					{field:'charge_user_name',title:'负责人',width:60},
  					//{field:'charge_user_id',title:'负责人',width:0},
  					{field:'priority',title:'优先级',width:30,formatter:pmpFormat.formatPriority},
  					{field:'difficulty_score_name',title:'任务难度',width:60},
  					{field:'assign_hours',title:'指派时间',width:40},
  					{field:'work_hours',title:'投入时间',width:40},
  					{field:'progress',title:'进度',width:100,formatter:pmpFormat.formatProcess},
  					{field:'createTime',title:'创建时间',width:120},
  					{field:'expiry_time',title:'截止时间',width:120},
  					{field:'from_require',title:'来源',width:60,formatter:pmpFormat.formatTaskFrom},
  					{field:'status',title:'状态',width:100,formatter:pmpFormat.formatTaskStatus},
  					{field:'expired',title:'是否延期',width:100,formatter:pmpFormat.formatTaskExpired}];
  		  var url="/pmp/service/pm/pmpTasks/loadPmpTasksDataSet";
    		zfesBstable.laodTable($("#pmpTasksBootstrapTable"),$("#biz_pmpTasks_searchForm"),$("#pmpTasksTableToolbar"),url,columns,this.searchForm);
  	  },
  	  search:function(){
  		  zfesBstable.reload($("#pmpTasksBootstrapTable")); 
  	  },
  	  refresh:function(){
  		  zfesBstable.refresh($("#pmpTasksBootstrapTable"));
  	  },
  	  add:function(){
  	    var　_this=this;
		var url="/views/pmpTasks/pmpTasks.add.html";
		zfesLayerEditDg.open(url,{"projectId": _this.searchForm.projectId,"projectVersionId": _this.searchForm.projectVersionId},"添加任务",660,function(){_this.refresh();}); 
		 
  	},
  	  split:function(){
  		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
  			  var　_this=this;
  			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
  			  var url="/views/pmpTasks/pmpTasks.split.html";
  			  zfesLayerEditDg.open(url,{"taskId":id},"拆分任务",600,function(){_this.refresh();}); 
  		 }
  	  },
  	 assign:function(){
		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
			  var　_this=this;
			  var rows=zfesBstable.getSelections($("#pmpTasksBootstrapTable"));
			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
			  var url="/views/pmpTasks/pmpTasks.assign.html";
			  zfesLayerEditDg.open(url,{"id":id,"chargeUserId":rows[0].charge_user_id},"任务指派",460,function(){_this.refresh();}); 
		 }
	  },
	  assignHours: function(){
  		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
  			  var　_this=this;
  			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
  			var rows=zfesBstable.getSelections($("#pmpTasksBootstrapTable"));
  			  var url="/views/pmpTasks/pmpTasks.assignHours.html";
  			  zfesLayerEditDg.open(url,{"id":id,"assignHours":rows[0].assign_hours},"评估时间编辑",460,function(){_this.refresh();}); 
  		 }
  	  },
  	 difficultyScore:function(){
 		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
 			  var　_this=this;
 			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
 			 var rows=zfesBstable.getSelections($("#pmpTasksBootstrapTable"));
 			  var url="/views/pmpTasks/pmpTasks.assignDifficulty.html";
 			  zfesLayerEditDg.open(url,{"id":id,"difficultyScoreId":rows[0].difficulty_score_id},"任务难度编辑",460,function(){_this.refresh();}); 
 		 }
 	  },
 	  
 	 expireTime:function(){
		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
			  var　_this=this;
			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
			  var rows=zfesBstable.getSelections($("#pmpTasksBootstrapTable"));
			  var url="/views/pmpTasks/pmpTasks.assignExpiry.html";
			  zfesLayerEditDg.open(url,{"id":id,"expiryTime":rows[0].expiry_time},"任务延期",460,function(){_this.refresh();}); 
		 }
	  },
	  assignVersion: function(){
		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
			  var　_this=this;
			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
			  var rows=zfesBstable.getSelections($("#pmpTasksBootstrapTable"));
			  var url="/views/pmpTasks/pmpTasks.assignVersion.html";
			  zfesLayerEditDg.open(url,{"id":id,"projectVersionId":rows[0].project_version_id},"任务版本",460,function(){_this.refresh();}); 
		 }
	  },
	  check: function(){
		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
			  var　_this=this;
			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
			  var rows=zfesBstable.getSelections($("#pmpTasksBootstrapTable"));
			  var url="/views/pmpTasks/pmpTasks.check.html";
			  zfesLayerEditDg.open(url,{"id":id},"任务验收",460,function(){_this.refresh();}); 
		 }
	  },
	  submit:function(){
 		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
 			  var　_this=this;
 			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
 			 var rows=zfesBstable.getSelections($("#pmpTasksBootstrapTable"));
 			 //任务状态_D#1未指派,2未开始,3进行中,4已提交,5被驳回,6已完成,-1已删除#
 			 if(rows[0].progress>=100&&(rows[0].status==4||rows[0].status==6||rows[0].status==-1||rows[0].status==1)){
 				alertSwal.warning("当前任务不允许提交");return;
 			 }
 			  var url="/views/pmpTasks/pmpTasks.submit.html";
 			  zfesLayerEditDg.open(url,{"id":id,"work_hours":rows[0].work_hours,"task_name":rows[0].task_name,"assign_hours":rows[0].assign_hours,"progress":rows[0].progress},"任务提交",460,function(){_this.refresh();}); 
 		 }
 	  },
 	 updateName:function(){
 		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
 			  var　_this=this;
 			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
 			  var url="/views/cloudMember/cloudMember.setUserLogo.html";
 			  zfesLayerEditDg.open(url,{"id":id},"任务名称编辑",600,function(){_this.refresh();}); 
 		 }
 	  },
 	 start:function(){
 		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
 			  var　_this=this;
 			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
 			  var url="/pmp/service/ma/pmpTasks/setPmpTasksStatus";
 			 zfesAjax.ajaxTodo(ajaxUrl, { "id" : id,"status" : "3"}, function(data) {
					alertSwal.successText(data.message);
					_this.refresh();
				});  
 		 }
 	  },
	  refuse:function(){
 		  if(zfesBstable.isOneRow($("#pmpTasksBootstrapTable"))){
 			  var　_this=this;
 			  var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
 			 var url="/pmp/service/ma/pmpTasks/setPmpTasksStatus";
 			 zfesAjax.ajaxTodo(ajaxUrl, { "id" : id,"status" : "5"}, function(data) {
					alertSwal.successText(data.message);
					_this.refresh();
				});   
 		 }
 	  },
  	  deletex:function(){
  			if(zfesBstable.isSelectedRow($("#pmpTasksBootstrapTable"))){
  				  var　_this=this;
  				    var id=zfesBstable.getRowId($("#pmpTasksBootstrapTable"));
  					//var ids=zfesBstable.getRowIds($("#cloudMemberBootstrapTable"));
  					 alertSwal.confirm("删除","是否删除该任务",function(){
  						    var ajaxUrl = "/pmp/service/ma/pmpTasks/setPmpTasksStatus";
  							zfesAjax.ajaxTodo(ajaxUrl, { "id" : id,"status" : "-1"}, function(data) {
  								alertSwal.successText(data.message);
  								_this.refresh();
  							}); 
  				});
  			}
  				
  	  },
  	  formatType: function(value, row, index){
  		if("1"==value){return '[是]';}else{return '[否]';}
  	},
  	 formatStatus:function(value, row, index){
   		if("1"==value){
   			return '<span class="label label-warning">未指派</span>';
   		}else if("2"==value){
   			return '<span class="label label-warning">未开始</span>';
   		}else if("3"==value){
   			return '<span class="label label-success">进行中</span>';
   		}else if("4"==value){
   			return '<span class="label label-warning">已提交</span>';
   		}else if("5"==value){
   			return '<span class="label label-danger">被驳回</span>';
   		}else if("6"==value){
   			return '<span class="label label-success">已完成</span>';
   		}else{
   			return '<span class="label label-danger">已删除</span>';
   		}
   	},
  	formatexpired: function(value, row, index){
  		if("1"==value){
   			return '<span class="label label-warning">已超时</span>';
   		}else if("2"==value){
   			return '<span class="label label-success">正常</span>';
   		}
  	}
   	
   }

});
</script>


